
<template>
  <!-- 修改窗口 -->
  <a-modal v-model:visible="visible" title="修改商品信息" @ok="execUpd">
    <a-form
      :model="updObj"
      :label-col="{ span: 5 }"
      :wrapper-col="{ span: 14 }"
    >
      <a-form-item label="商品id">
        <a-input v-model:value="updObj.ca_id"  disabled/>
      </a-form-item>
      <a-form-item label="商品名称">
        <a-input v-model:value="updObj.ca_name"/>
      </a-form-item>
      <a-form-item label="商品保质期">
        <a-input v-model:value="updObj.ca_date" />
      </a-form-item>
      <a-form-item label="商品价格">
        <a-input v-model:value="updObj.ca_price" />
      </a-form-item>
      <a-form-item label="单位">
        <a-input v-model:value="updObj.im_unit" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>
<script>
import { ref, reactive } from "vue";
import { get, put, post, tip, del } from "@/common";
export default {
  setup(props, { emit }) {
    const updObj = reactive({
      ca_id: "",
      ca_name: "",
      ca_date: "",
      ca_price: "",
      im_unit: "",
    });
    const visible = ref(false);
    const openUpd = (sup) => {
        updObj.ca_id=sup.ca_id;
        updObj.ca_name=sup.ca_name;
        updObj.ca_date=sup.ca_date;
        updObj.ca_price=sup.ca_price;
        updObj.im_unit=sup.im_unit;
      visible.value = true;
    };
    const execUpd = () => {
      put("/cargo/manage", updObj).then((res) => {
        (updObj.ca_id = ""),
        (updObj.ca_name = ""),
        (updObj.ca_date = ""),
        (updObj.ca_price = ""),
        (updObj.im_unit = ""),
        (visible.value = false);
        tip.success("修改成功");
        emit("flash");
      });
    };
    return {
      openUpd,
      updObj,
      visible,
      execUpd,
    };
  },
};
</script>
<style scoped>
</style>
